#ifndef _NOR_SWSPI_FLASH_H_
#define _NOR_SWSPI_FLASH_H_

#include "stdint.h"
#include "nor_cmd.h"

#ifdef __cplusplus
extern "C"
{
#endif

	// base interface
	void nor_spi_init(void);
	void nor_spi_cs(uint8_t st);
	void nor_hal_mode_spi(void);
	void nor_hal_mode_qpi_out(void);
	void nor_hal_mode_qpi_in(void);
	void nor_spi_high_speed(void);
	void nor_spi_low_speed(void);

	// spi data r/w
	uint8_t nor_spi_rb(void);
	void nor_spi_wb(uint8_t dataW);

	uint8_t nor_spi_cmd_send(const uint8_t *dataw, uint8_t Len);
	uint8_t nor_qpi_cmd_send(const uint8_t *dataw, uint8_t Len);
	uint8_t nor_spi_cmd_read(uint8_t *datar, uint8_t Len);
	uint8_t nor_qpi_cmd_read(uint8_t *datar, uint8_t Len);

	// data r/w
	uint8_t nor_spi_write(const uint8_t *dataw, uint32_t Len);
	uint8_t nor_spi_read(uint8_t *datar, uint32_t Len);
	uint8_t nor_qpi_write(const uint8_t *dataw, uint32_t Len);
	uint8_t nor_qpi_read(uint8_t *datar, uint32_t Len);

	extern const spi_flash_hal_type sw_spi_nor;

#ifdef __cplusplus
}
#endif

#endif /* _NOR_SWSPI_FLASH_H_ */
